package top.kaoshanji.p2ch16a;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * 代码清单-p2ch16a-180页d：场景类
 * @author kaoshanji
 * ^_^
 * create time 2025/3/23 18:44
 */
public class Client {

    public static void main(String[] args) {

        // 随机挑选几个女性
        Random rand = new Random();
        List<IWomen> list = new ArrayList<>();
        for (int i = 0; i < 5; i ++) {
            list.add(new Women(rand.nextInt(4), "我要出去逛街"));
        }

        // 定义三个请示对象
        IHandler father = new Father();
        IHandler husband = new Husband();
        IHandler son = new Son();

        for (IWomen women: list) {
            if (women.getType() == 1) { // 未结婚少女，请示父亲
                System.out.println("----------女儿向父亲请示------------");
                father.handleMessage(women);
            } else if (women.getType() == 2) { // 已婚少妇，请示丈夫
                System.out.println("----------妻子向丈夫请示------------");
                husband.handleMessage(women);
            } else if (women.getType() == 3) { // 母亲向儿子请示
                System.out.println("----------母亲向儿子请示------------");
                son.handleMessage(women);
            } else {
                // 暂时什么也不做
            }

        }



    }


}
